package org.example.cloudgetway.handler;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private ApiIdempotentInceptor apiIdempotentInceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        System.out.println("拦截222");
        // 白名单
        ArrayList<String> strings = new ArrayList<>();
        strings.add("/usr/toAddUser");
        registry.addInterceptor(apiIdempotentInceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(strings);
        WebMvcConfigurer.super.addInterceptors(registry);
    }

}
